package com.meatball.iot.driver.dtu.data.document

import cn.hutool.core.date.DateTime
import cn.hutool.core.date.DateUtil
import org.springframework.data.annotation.Id
import org.springframework.data.mongodb.core.mapping.Document
import java.math.BigDecimal
import java.time.Instant
import java.util.Date

/**
 * TODO dtu时序数据
 *
 * @property id 主键
 * @property deviceID 设备ID
 * @property frameCount 帧计数
 * @property groupActiveTotalEnergy 组合有功总电能
 * @property aVoltage A相电压
 * @property bVoltage B相电压
 * @property cVoltage C相电压
 * @property aCurrent A电流
 * @property bCurrent B电流
 * @property cCurrent C电流
 * @property instantTotalActivePower 瞬时总有功功率
 * @property totalPowerFactor 总功率因数
 * @property insertTimestamp 插入时间戳
 * @property rawData 原始数据
 */
@Document("DTU")
data class DtuDocument(
    @Id
    val id: String? = null,
    val deviceID: String,
    val frameCount: Int,
    val groupActiveTotalEnergy: BigDecimal,
    val aVoltage: BigDecimal,
    val bVoltage: BigDecimal,
    val cVoltage: BigDecimal,
    val aCurrent: BigDecimal,
    val bCurrent: BigDecimal,
    val cCurrent: BigDecimal,
    val instantTotalActivePower: BigDecimal,
    val totalPowerFactor: BigDecimal,
    val insertTimestamp: Long = System.currentTimeMillis(),
    val insertTime: String = DateUtil.formatDateTime(DateTime(insertTimestamp)),
    val rawData: String
)
